package pyrachnid.model.pathFinderModel;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

import pyrachnid.model.ground_model.Cell;

// A addapter
public class Noeud {

	private Double distance_cible;
	private Cell _cell;
	private Hashtable<Noeud, Double> arc;
	
	public Noeud(Double cible, Cell p_cell){
		arc = new Hashtable<Noeud, Double>();
		distance_cible = cible;
		_cell = p_cell;
	}
	
	public void add_noeud(double distance, Noeud autre_noeud) {
		 arc.put(autre_noeud, distance);
		 
		 /*
		 if(autre_noeud.distance_avec(this) != distance)
			 autre_noeud.add_noeud(distance, this);
			 */
	}
	
	public Double distance_avec(Noeud autre_noeud) {
		return (arc.get(autre_noeud) != null)?  arc.get(autre_noeud) : 0;
	}
	
	public Hashtable<Noeud, Double> successeur() {
		return arc;
	}
	
	public Double getDistance_cible() {
		return distance_cible;
	}
	
	public Cell getCell() {
		return _cell;
	}
	
	public void afficher() {
		Set<Noeud> set = arc.keySet();
		Noeud node;

		    Iterator<Noeud> itr = set.iterator();
		    while (itr.hasNext()) {
		      node = itr.next();
		      System.out.println("Distance avec "+ node.getCell()+ " = "+distance_avec(node));
		    }
	}
}
